package memory.GUI;

import java.awt.*;
import javax.swing.*;
import javax.swing.border.*;
import memory.Square;

public class SquarePanel extends JPanel {

    private final Square s;
    private final static int PREF_SIZE = 70;
    public final static Color DEFAULT_COLOR = Color.WHITE;
    private final JLabel label;

    public SquarePanel (Color c, int preferedSize, Square s) {
        this.s = s;
        setBackground(c);
        setSize(preferedSize, preferedSize);
        setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED, Color.WHITE, Color.GRAY));
        setLayout(new BorderLayout());

        label = new Image (s.getPairValue());

        //label = new JLabel(Integer.toString(s.getPairValue()), JLabel.CENTER);
        //label.setFont(new Font (Font.SANS_SERIF,Font.BOLD,30));
        //label.setForeground(Color.BLACK);
    }

    public SquarePanel (Color c, Square s) {
        this (c, PREF_SIZE, s);
    }

    public SquarePanel (int preferedSize, Square s) {
        this (DEFAULT_COLOR, preferedSize, s);
    }

    public SquarePanel ( Square s) {
        this (DEFAULT_COLOR, PREF_SIZE, s);
    }

    public Square getSquare () {
        return s;
    }

    public void setMatched() {
        this.setBackground(new Color (195,214,242));
        s.match();
    }

    public void setClicked() {
        this.setBackground(Color.CYAN);
    }

    public void displayImage() {
        add(label,BorderLayout.CENTER);
        validate();
        repaint();
    }

    public void removeNumber() {
        remove(label);
        validate();
    }

}
